package com.mybatis.basic.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class BasicFilter implements HandlerInterceptor{

	private static final Logger log = Logger.getLogger(BasicFilter.class);

	//处理请求之前
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
		String path = request.getServletPath();
		log.info("============处理["+path+"]请求之前=============");
		return true;
	}

	//处理请求之后，渲染视图之前
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object obj, ModelAndView model) throws Exception {
		log.info("============处理请求之后，渲染视图之前=============");		
	}

	//渲染视图之后，请求处理完毕
	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object obj, Exception ex) throws Exception {
		log.info("============渲染视图之后，请求处理完毕=============");
	}

}
